<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: ethen
  Date: 2024/10/27
  Time: 22:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    response.setCharacterEncoding("utf-8");
    // 表单提交的参数
    String stuid = request.getParameter("查");
%>
<%
    String user = "root";
    String password = "123123";
    String url="jdbc:mysql://localhost:3306/tb?serverTimezone=Asia/Shanghai";

    Class.forName("com.mysql.cj.jdbc.Driver");

    Connection conn = DriverManager.getConnection(url, user, password);

    Statement statement = conn.createStatement();

    String sql = "select * from newtable ";

    ResultSet rs = statement.executeQuery(sql);

%>
<table border="1">
    <th colspan="4" style="font-size: x-large;alignment: center">学生信息表</th>
    <tr>
        <td>学号</td>
        <td>姓名</td>
        <td>出生日期</td>
        <td>所在班级</td>
    </tr>
        <% while(rs.next()){ %>
    <tr>
        <td><%=rs.getString(1)%></td>
        <td><%=rs.getString(2)%></td>
        <td><%=rs.getString("birthday")%></td>
        <td><%=rs.getString("classname")%></td>
    </tr>
        <%}%>
        <%
       // 先开后关 的原则
        rs.close();
        statement.close();
        conn.close();
    %>

</body>
</html>
